<style lang="less">
.xs_list .nums span:last-child {
	margin-left:0;
}
/* .pop_up{
	.van-popup {
		width: 85%;
		padding: 10px;
		text-align: left;
		font-size: 14px;
		.list_box{
			font-size:14px;
			border-bottom:1px dotted #ddd;
			.title {
				display: inline-block;
				width: 30%;
			}
		}
	}
} */
</style>

<template>
	<mxq-router-layout>
		<div class="line-list">
			<Head slot="header" @headerClick="headerClick($event)">
				<div slot="headerTitle">
					<span>保电值守</span>
				</div>
				<div slot="headerRight">
					<i class="iconfont icon-shouye"/>
					<!-- <van-icon class="home" name="home"/> -->
				</div>
			</Head>
			<xs-list
				:list = "taskLists"
				:listLeftImg="listLeftImg"
				:listTitle="listTitle"
				@listClick="listClick($event)"/>

			<!-- <div class="pop_up">
				<van-popup v-model="importantInform">
					<span class="title">重要告知：</span>
					<span class="name">{{importInform}}</span>
				</van-popup>
			</div> -->
		</div>
	</mxq-router-layout>
</template>

<script>
import Head from '../../../components/head'
import XsList from '../../../components/xs-list'
import IconWks from '../../../assets/img/changguixunshi/icon_wks.png'
import IconJxz from '../../../assets/img/changguixunshi/icon_jxz.png'
import IconYwc from '../../../assets/img/changguixunshi/icon_ywc.png'
import { callData } from '../../../axios/axios'

import {
	Icon,
	Popup,
	Dialog
} from 'vant'

export default {
    components: {
		[Icon.name]: Icon,
		[Popup.name]: Popup,
		Head,
        XsList
	},
	data() {
		return {
			active: '',	
			taskLists: [ ],
			listLeftImg:[IconWks,IconJxz,IconYwc],
			listTitle: ['任务名称:','时间:',' 至 '],
			importantInform: false,	//是否显示重要告知
			importInform: '',		//重要告知弹框内容
			params: this.$route.query,
			infoCont: ''
		}
	},
	mounted() {
		this.getTaskList()
    },
    methods: {
		// 头部两侧按钮点击事件
		headerClick(e){
			this.$router.push({name:"index"})
		},
		// 跳页
		listClick(e){
			if(e.todo==0){
				/* if(e.data.KEY_INFO){
					this.importantInform = true;
					this.importInform = e.data.KEY_INFO;
				} */
				if(e.data.KEY_INFO){
	        		Dialog.alert({
					  title: '重要告知',
					  message: e.data.KEY_INFO
					}).then(() => {
					  // on close
					});
	        	}
			}else {
				this.$router.push({
					name:'bdzs_gantaXunshi',
					query: {
						zsTaskId: e.data.ID,
						//status: e.STATUS,//任务的状态
						page: 0,
						size: 8,
						index: this.params.index	//taskType任务类型
					}
				})
			}
		},
		// 拿到任务列表页数据
		getTaskList() {
			var params = {};
			params.page = 0;
			params.size = 8;
			params.status = 0; //不传查所有，0只查未完成的，1已完成
			callData('/zsTaskServer/ZsBdTowerTask/appZsBdTasks','get',params).then(res => {
				var bdzsData = res.data.content;
				bdzsData.forEach((item,index) => {
					item.line = item.TASK_NAME; //任务名称
					item.gtnum = item.PLAN_START_TIME; //任务名称
					item.wxsnum = item.PLAN_END_TIME; //任务名称
					item.id = item.ID;
					if(item.KEY_INFO == null){
						item.alarm = false
					}else{
						item.alarm = true
						this.keyInfo = item.KEY_INFO;
					}
					// 状态判断
					if (item.STATUS == 0) {
						item.status = item.STATUS;
						item.statusName = '未开始';
						item.cname="btn_status";
						item.cname1="btn_statusNo";
					}else if (item.STATUS == 1) {
						item.status = item.STATUS;
						item.statusName = '进行中';
						item.cname="btn_status1";
						item.cname1="btn_statusNo";
					}else if(item.STATUS == 2) {
						item.status = item.STATUS;
						item.statusName = '已完成';
						item.cname="btn_status2";
						item.cname1="btn_statusNo";
					}
				})
				this.taskLists = bdzsData;
			})
		}
	}
}
</script>
